package bTree.LeetCode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

public class 重复的DNA序列 {
    public List<String> findRepeatedDnaSequences(String s) {
        List<String>res=new ArrayList<>();
        HashMap<String,Integer>hashMap=new HashMap<>();
        int length = s.length();
        for (int i = 0; i < length - 9; i++) {
            String substring = s.substring(i, i + 10);
            if(hashMap.containsKey(substring)&&hashMap.get(substring)==1){
                res.add(substring);
                hashMap.put(substring,2);
            }
            if(!hashMap.containsKey(substring)){
                hashMap.put(substring,1);
            }
        }
        return res;
    }

}